package calao.client.ui;

import com.google.gwt.i18n.client.DateTimeFormat;

import calao.client.util.CalendarDate;

public class WeekDayBox
extends NumberedListBox
{

	String[] dayNames = new String[7];
	
	public WeekDayBox()
	{
		DateTimeFormat format = DateTimeFormat.getFormat("EEEE");
		CalendarDate date = new CalendarDate();
		for (int i=0; i<dayNames.length; i++) {
			dayNames[date.getWeekDay()] = format.format(date.getTime());
			date.incDay(1);
		}
		refresh();
	}
	
	protected int getItemCount() 
	{
		return dayNames.length;
	}

	protected long getItemNumber(int index) 
	{
		return index;
	}

	protected String getItemText(int index) 
	{
		return dayNames[index];
	}
	
	public void setWeekDay(int day)
	{
		setNumberSelected(day);
		refresh();
	}
	
	public int getWeekDay()
	{
		return getFirstSelected();
	}
	
	public String getWeekDayText(int weekDay)
	{
		return getItemText(weekDay);
	}

}
